package demo1;

import java.io.IOException;
import java.net.SocketException;
import java.util.*;
public class UdpDictService extends UdpEchoService{
    Map<String,String> dict = new HashMap<>();
    public UdpDictService(int port) throws SocketException {
        super(port);
        F();
    }
    private void F() {
        dict.put("hello","vt.哈喽");
        dict.put("he","pron.他");
        dict.put("dog","n.狗");
        dict.put("cat","n.猫");
        dict.put("student","n.学生");
        dict.put("parent","n.父母");
        dict.put("chip","n.木屑,碎片;缺口");
        dict.put("contrary","adj.对立的,相反的;叛逆的");
        dict.put("infer","vt.推断;暗示");
        dict.put("plug","vt.插入(插头),接通(电源)");
        dict.put("emphasise","v.强调;着重,重读");
        dict.put("instruct","vt.指导，教;指示；通知");
        dict.put("criticize","v.批评,评论");
        dict.put("considerable","adj.相当大的;重要的;可观的");
        dict.put("judgment","n.判决,审判");
        dict.put("enterprise","n.企业(或事业)单位,公司,事业");
        dict.put("communication","n.沟通方式;通信;交流;信息");
        dict.put("depress","vt.使沮丧;使萧条");
        dict.put("investigate","v.调查,查明,研究");
    }

    @Override
    public String service(String response) {
        return dict.getOrDefault(response,"您的单词拼错了");
    }

    public static void main(String[] args) throws IOException {
        UdpDictService udpDictService = new UdpDictService(520);
        System.out.println("我是子类服务器");
        udpDictService.start();
    }
}
